<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>addAdmin</title>
</head>

<body>
 <?php
    include ("../../Connections/cpsms.php");
	$adminname = $_POST['adminname'];
	$phone = $_POST['phone'];
	$email = $_POST['email'];
		$loginname = $_POST['loginname'];
	$adminpassword = $_POST['adminpassword'];
	$checkpassword = $_POST['checkpassword'];
	$cofiguration = $_POST['cofiguration'];
 	$query = "select * from adminster where aloginname='$loginname';";
	$sql = mysql_query($query) or die(mysql_error());
	$array = mysql_fetch_array($sql);
if($adminname == NULL or $phone == NULL or $email == NULL or $loginname == NULL or $adminpassword == NULL or $checkpassword == NULL or $cofiguration == NULL){
echo "<script language='javascript'>location='../../view/Admin/addAdmin.php?id=4';</script>";
exit;
}else if($array != NULL){
	 echo ("User error! Please check your user loginname and user password");
	 echo "<script language='javascript'>location='../../view/Admin/addAdmin.php?id=1';</script>";
	 exit;
}else if($adminpassword != $checkpassword){
	 echo ("Super login name already be used!");
	 echo "<script language='javascript'>location='../../view/Admin/addAdmin.php?id=2';</script>";	
	 exit; 
}else if($cofiguration != 'confguraddadmin'){
	 echo ("Super login name already be used!");
	 echo "<script language='javascript'>location='../../view/Admin/addAdmin.php?id=5';</script>";	
	 exit; 
}else{
    mysql_query("INSERT INTO cpsms.adminster (aloginname, aloginpassword, aname, aphone, aemail) 
	VALUES ('$loginname', '$adminpassword', '$adminname', $phone, '$email');");
	echo ("Success!");
	echo "<script language='javascript'>location='../../view/Admin/addAdmin.php?id=3';</script>";
	exit;
        }

 ?>   
</body>
</html>
